//
//  YLWTabBarController.m
//  推库iOS
//
//  Created by Mac on 16/2/17.
//  Copyright © 2016年 YLW. All rights reserved.
//

#import "YLWTabBarController.h"
//#import "YLWHomeViewController.h"
//#import "YLWSiteViewController.h"
//#import "YLWTopicViewController.h"
//#import "YLWWeeklyViewController.h"
//#import "YLWUserViewController.h"
#import "XXNavigationController.h"
#import "HomePageViewController.h"

@interface YLWTabBarController ()

@end

@implementation YLWTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    

    [self addChildViewControllers];
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(yoohooGo) name:@"YoohooGo" object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(yoohooGohome) name:@"YoohooGohome" object:nil];

    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(NiceFoodGo) name:@"dismissFiveButton" object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(NiceFoodGohome) name:@"showFiveButton" object:nil];

    
}

-(void)NiceFoodGo{
    CGRect rect=CGRectMake(ACTUAL_WIDTH(237), 0, KScreenWidth, KScreenHeight);
    [UIView animateWithDuration:0.5 animations:^{
        self.view.frame=rect;
    }];

}
-(void)NiceFoodGohome{
    CGRect rect=CGRectMake(0, 0, KScreenWidth, KScreenHeight);
    [UIView animateWithDuration:0.5 animations:^{
        self.view.frame=rect;
    }];

}

-(void)yoohooGo{
    CGRect rect=CGRectMake(ACTUAL_WIDTH(250), 0, KScreenWidth, KScreenHeight);
    [UIView animateWithDuration:0.5 animations:^{
        self.view.frame=rect;
    }];
    
}

-(void)yoohooGohome{
    CGRect rect=CGRectMake(0, 0, KScreenWidth, KScreenHeight);
    [UIView animateWithDuration:0.5 animations:^{
        self.view.frame=rect;
    }];
    
}


-(void)addChildViewControllers{

    HomePageViewController *homeVc = [[HomePageViewController alloc]init];
    [self addChildViewController:homeVc WithTitle:@"首页" image:@"tabBar_home_numal"];
    
    HomePageViewController *site = [[HomePageViewController alloc]init];
    [self addChildViewController:site WithTitle:@"美食" image:@"tab_food"];
    
    HomePageViewController *topic = [[HomePageViewController alloc]init];
    [self addChildViewController:topic WithTitle:@"逛街" image:@"tabBar_rocket"];
    
    HomePageViewController *weekly = [[HomePageViewController alloc]init];
    [self addChildViewController:weekly WithTitle:@"购物车" image:@"tabBar_shopCar_noma"];
    
    HomePageViewController *user = [[HomePageViewController alloc]init];
    [self addChildViewController:user WithTitle:@"个人中心" image:@"tabBar_gerenzhongxin_nomal"];


}


-(void)addChildViewController:(UIViewController *)childController WithTitle:(NSString *)title image:(NSString *)imageName{
    
    childController.tabBarItem.image = [UIImage imageNamed:imageName];
    
    childController.title = title;
    
    
    XXNavigationController *nav = [[XXNavigationController alloc]initWithRootViewController:childController];
//    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:childController];
//
//    [nav.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
//
//    nav.navigationBar.barTintColor = [UIColor colorWithRed:22.0/255.0 green:147.0/255.0 blue:114.0/255.0 alpha:1.0];
    
    
    
    [self addChildViewController:nav];

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
